package com.dongdongshop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.data.Result;
import com.dongdongshop.em.ResultEnum;
import com.dongdongshop.pojo.TbContent;
import com.dongdongshop.service.ContentService;
import com.dongdongshop.service.TbUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("indexController")
public class IndexController {

    @Reference
    private ContentService contentService;

    @Reference
    private TbUserService tbUserService;

    @RequestMapping("index")
    public String index(){
        return "index";
    }

    @RequestMapping("getContent")
    @ResponseBody
    public Result getContent(Long categoryId,Integer pageSize){
        try{
            List<TbContent> list = contentService.getContent(categoryId,pageSize);
            return Result.response(ResultEnum.SUCCESS).setData(list);
        }catch (Exception e){
            return Result.response(ResultEnum.ERROR).setData(e);
        }
    }

    //跳转登录页面
    @RequestMapping("login")
    public String login(){
        return "login";
    }

    //跳转注册页面
    @RequestMapping("register")
    public String register(){
        return "register";
    }




}